package com.tangchao.client.sdh.view.jiaoFen
{
	import com.tangchao.client.sdh.event.JiaoFenEvent;
	
	import flash.display.MovieClip;
	import flash.events.MouseEvent;

	public class JiaoFenGrid extends MovieClip
	{
		private var _jiaofenArray:Array=[];
		private var _nowNum:int=-1;
		private var _nowMaxNum:int=80;
		
		static private var MAXJIAOFENCOUNT:int = 16;
		
		public function JiaoFenGrid()
		{
			init();
		}
		
		private function init()
		{
			var i:int=0;
			for(i=MAXJIAOFENCOUNT;i>=0;i--)
			{
				var num:int=i*5;
				var cell:JiaoFenCell=new JiaoFenCell();
				cell.canSelect = false;
				cell.num=num;
				addChild(cell);
				cell.x=_jiaofenArray.length%5*60+15;
				cell.y=int(_jiaofenArray.length/5)*40;
				_jiaofenArray.push(cell);
			}	
		}
		
		/*
		*设置最高可以叫的分
		*/
		public function set maxNum(value:int):void
		{			
			var i:int;
			var cell:JiaoFenCell;
			
			if(value<0 || value>80)
			{
				return;
			}
			
			for(i=MAXJIAOFENCOUNT;i>=0;i--)
			{
				cell = _jiaofenArray[i] as JiaoFenCell;
				if(cell && cell.num<= value)
				{
					cell.canSelect = false;
				}
			}
			
			for(i=MAXJIAOFENCOUNT;i>=0;i--)
			{
				cell = _jiaofenArray[i] as JiaoFenCell;
				if(cell && cell.num<= value)
				{
					cell.canSelect = true;
				}
			}
		}
		
//		public function get num():int
//		{
//			return _nowNum;
//		}
		
//		private function updataSelect()
//		{
//			var i:int=0;
//			for(i=0;i<_jiaofenArray.length;i++)
//			{
//				var cell:JiaoFenCell=_jiaofenArray[i] as JiaoFenCell;
//				if(cell)
//				{
//					if(cell.num>_nowMaxNum)
//					{
//						cell.selectState(3);
//					}
//					else if(cell.num==_nowNum)
//					{
//						cell.selectState(2);
//					}
//					else
//					{
//						cell.selectState(1);
//					}
//				}
//			}
//		}
	}
}